GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

position.js ➔ isCoordinates   A
last analyzed

Complexity

Conditions 1
Paths 2

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
c 0
b 0
f 0
nc 2
nop 2
dl 0
loc 3
rs 10
1
"use strict";
2
3
var _ = require('lodash');
4
5
// Expose `Position`
6
7
module.exports = Position;
8
9
var cardinalPoints = ['N','E','S','W'];
10
11
/**
12
 * Set up Position with `coordinate` and `cardinal`
13
14
 * @param {Object} coordinate
15
 * @param {String} cardinal
16
 * @api public
17
 */
18
19
function Position(coordinate, cardinal) {
20
    this.x = coordinate.x;
21
    this.y = coordinate.y;
22
    this.c = cardinal;
23
24
    this.isValid();
25
}
26
27
/**
28
 * Types validator
29
 *
30
 * @api public
31
 */
32
33
Position.prototype.isValid = function() {
34
    if(!isCoordinates(this.x,this.y)) {
35
        throw new Error('Coordinates are not valid');
36
    }
37
    if(!isCardinal(this.c)) {
38
        throw new Error('Cardinal point is not valid');
39
    }
40
};
41
42
/**
43
 * Coordinates validator helper
44
 *
45
 * @param {Number} x
46
 * @param {Number} y
47
 * @api protected
48
 */
49
50
function isCoordinates(x,y) {
51
    return x === parseInt(x, 10) && y === parseInt(y, 10);
52
}
53
54
/**
55
 * Cardinal validator helper
56
 *
57
 * @param {String} cardinal
58
 * @api protected
59
 */
60
61
function isCardinal(cardinal) {
62
    return _.isString(cardinal) && !_.isUndefined( _.find(cardinalPoints, function(c) { return c === cardinal; }) );
63
}
64